#pragma once

#include <QtGui>

class table_view2
        : public QTableView
{
    Q_OBJECT

public:
    explicit table_view2(int min_row_to_show, int min_col_to_show, QWidget *parent = 0);

    void create_table(int row, int col);
    void add_row();
    void del_row();
    void add_col();
    void del_col();

    void auto_resize();

    void clear_table();

    void print_sizes();

    QSize sizeHint() const override;

    void resizeEvent(QResizeEvent *e) override;

private:
    int sizeHintForColumn(int column) const override;
    int sizeHintForRow   (int row)    const override;

private:
    int min_width_for_content() const;
    int min_height_for_content() const;

private:
    QStandardItemModel *model_;
    int                 min_row_to_show_;
    int                 min_col_to_show_;
};

